<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="author" content="LiuWeiLiang">
	<title>退货处理</title>
	<script language="javascript" src="../script/common.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">
		
		function load(){
			$('cancelForm').reset();
			Eui.showNavigation();
			$("tradeTimeTd").innerHTML = Eui.getDateInput("交易时间","cancelForm","occurTime","dateTime",true,true);
			setPages(["cancelForm","printSheetDiv","billDiv"]);
		}
		
		function cancelConsume(){
			if(!checkForm(cancelForm)){ return;}
			var data = Common.getValues(cancelForm);
			var origAmount = parseInt(Format.yuanToFen(data.origAmount))
			var amount = parseInt(Format.yuanToFen(data.amount))
			
			if(amount > origAmount){
				showError("退货金额不能大于原交易金额")
				return
			}
			
			DWR.call("tradeService.cancelCardConsume",
					data.asn,
					data.occurTime,
					origAmount,
					amount,
					function(result){
						showInformation("退货成功");
//						TX.Trade.showResult(result);
						//显示票据打印
						Eui.getBillHtml('content',{queryName:'consume_cancel_bill',tradeId:result.id})
						switchPage("billDiv")
					},{blockScreen:true}
					);
		}
		
		function backToLast(){
			cancelForm.reset();
			switchPage("cancelForm");
		}
	</script>
</head>
<body onload="load()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id=detview align=center>
		<form id="cancelForm" name="cancelForm">
			<div class=form>
				<div class="formTitle">退货处理</div>
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" id = "cancelConsumeTable" class="col2 label6">
					<tr>
						<td ><label>卡&nbsp;&nbsp;&nbsp;&nbsp;号</label> <input type="text" name="asn" maxlength="16" onblur="checkV(this,'asn',true)"><span class="des">*</span></td>	
						
						<td id="tradeTimeTd">&nbsp;</td>
					</tr>
					<tr>
						<td ><label>原交易金额</label> <input type="text" name="origAmount" onblur="checkV(this,'positiveAmount',true)"><span class="des">*</span></td>
						<td ><label>退货金额</label> <input type="text" name="amount"  onblur="checkV(this,'positiveAmount',true)"><span class="des">*</span></td>
					</tr>
				</table>
			</div>
			<p>
				<td><button id="rcBtn" onclick="cancelConsume()">退 货</button></td>
			</p>
		</form>
	</div>
	
	<div id="printSheetDiv" style="display:none;">
		<div class="form">
			<div class="formTitle">退货明细</div>
			<div id="mainTrade"></div>
		</div>
		<p>
			<button onclick="backToLast()">返 回</button>
		</p>
	</div>
	<div id="billDiv" class="form" width="100% " style="display:none;">
			<div class="formTitle">
				<div class="l">交易凭证</div>
				<div class="r">
					<button onclick="WebPrint.preview('content')">打印预览</button>
			 		<button onclick="WebPrint.print('content')">打印</button>
			 		<button onclick="backToLast()">返 回</button>
				</div>
			</div>
			<div  id="content"  align='center'></div>
		</div>
</body>
</html>